using UnityEngine;

public class INT_RunComponentFunctionAtEndOfChat : MonoBehaviour
{
	[Header("WARNING! This component is removed once ran")]
	[Space(20f)]
	public INT_Chat TargetChat;

	public CHATBOXTEXT TargetTextbox;

	public Component TargetComponent;

	[Space(5f)]
	public string MethodName;

	private void Update()
	{
		if (TargetChat.FinishedText && (Object)(object)ChatboxManager.Instance.previouschatboxtext == (Object)(object)TargetTextbox)
		{
			if ((Object)(object)TargetComponent != (Object)null && ((object)TargetComponent).GetType().GetMethod(MethodName) != null)
			{
				((object)TargetComponent).GetType().GetMethod(MethodName).Invoke(TargetComponent, null);
			}
			else
			{
				MonoBehaviour.print((object)((Object)TargetComponent.gameObject).name);
				MonoBehaviour.print((object)MethodName);
				MonoBehaviour.print((object)"did you forget to make the method public?");
			}
			Object.Destroy((Object)(object)this);
		}
	}
}
